$(function(){
	var param = $("#tabContent > .tab-pane.active").data();//上一层页面传来的参数
	paramTabPage[tabId] = param;//将上一个页面的值复制给这个页面
	showCondition(false);//让此页面不显示搜索条件
	var roleName = $("#roles").text();//获取登陆角色
	$("#"+tabId+" #drgCode").html(paramTabPage[tabId].name);//左上角显示drg代码和描述
	var compareType = paramTabPage[tabId].compareType;//比较类型
	//根据传入的比较类型，显示不同的标题
	if(compareType=="manage"){
		$("#"+tabId+" .comType").html("超标[绩效]病例数<span data-toggle='keyDisGroAnal13Quad_tooltip' remark_title='平均住院日或次均费用超标的病例' style='color: #0072ff;'>[注]</span>");
	} 
	else if(compareType=="std")
	{
		$("#"+tabId+" .comType").html("超标[标杆]病例数<span data-toggle='keyDisGroAnal13Quad_tooltip' remark_title='平均住院日或次均费用超标的病例' style='color: #0072ff;'>[注]</span>");
	}
	else{
		$("#"+tabId+" .comType").html("超标[院内均值]病例数<span data-toggle='keyDisGroAnal13Quad_tooltip' remark_title='平均住院日或次均费用超标的病例' style='color: #0072ff;'>[注]</span>");
	}	
	$(document).ajaxStop(function() {
		//备注的tiptitle
		$('[data-toggle="keyDisGroAnal13Quad_tooltip"]').mouseover(function(event){
			$.justToolsTip({
				events:event,
		        animation:"moveInTop",
		        //width:"300px",
		        contents:$(this).attr('remark_title'),
		        gravity:'top'
		    });
		});
	});
	//初始化滑块
	initSlider() ;
	getCaseFeeDistribute() ;//加载病例费用分布数据
	//加载趋势图
	keyDisGroupTrendChart('AvgDaysθAvgFee') ;
	// 病组表格列
	var drgDayFeeTableColumns = drgTableColumnsCommon.slice() ;
	drgDayFeeTableColumns.splice(7,0,{"data": "AvgDays_TF"},{"data": "AvgFee_TF"});
	// 科室表格列
	if(roleName=="科室"){//depTableColumnsCommon全局变量，如果是科室角色，则重新赋值
		depTableColumnsCommon = [
                                 {"data": "code"},
	        	                  	{"data": "desc"},
	        	                  	{"data": "InCaseCnt", "render":function(obj, type, full) {
	        	                  			if(full.InCaseCnt == 0){
		        		                    	return full.InCaseCnt ;
				                			} else {
		        		                    	return "<a href=\"javascript:void(0);\" onclick= \"loadCaseDtl('入组病例数','"+full.code+"','clinic', 'InCaseCnt')\">"+full.InCaseCnt+"</a>";
				                			}
	        		                	}
	                                },
	        	                  	{"data": "AvgDays"},
	        	                  	{"data": "AvgFee"},
	        	                  	{"data": "ExcessCnt_TF",
		    	                  		"render":function(obj, type, full) {
		    	                  			if(full.ExcessCnt_TF == 0){
		        		                    	return full.ExcessCnt_TF ;
				                			} else {
			    		                    	return "<a href=\"javascript:void(0);\" onclick= \"loadCaseDtl('费用及住院日超标病例数','"+full.code+"','clinic', 'ExcessCnt_TF')\">"+full.ExcessCnt_TF+"</a>";
				                			}
		    		                      }
		    	                  	},
		    	                  	{"data": "SpecificCnt_TF",
		    	                  		"render":function(obj, type, full) {
		    	                  			if(full.SpecificCnt_TF == 0){
		        		                    	return full.SpecificCnt_TF ;
				                			} else {
			    		                    	 return "<a href=\"javascript:void(0);\" onclick= \"loadCaseDtl('费用及住院日特异病例数','"+full.code+"','clinic', 'SpecificCnt_TF')\">"+full.SpecificCnt_TF+"</a>";

				                			}
		    		                	}
		    	                  	},
	        	                  	{"data": "operation",
	        	                  		"render":function(obj, type, full) {
	        		                    	  return "<a href=\"javascript:void(0);\" keyDisGroupCode = '"+full.code+"'><i class = 'fa fa-line-chart'></i></a>";
	        		                      }
	                          		},
	        	                 ] ;
	}
	var drgDepDayFeeTableColumns = depTableColumnsCommon.slice() ;
	drgDepDayFeeTableColumns.splice(7,0,{"data": "AvgDays_TF"},{"data": "AvgFee_TF"}) ;
	var quotas_drgDayFeeTable = ['InCaseCnt','AvgDays','AvgFee','CMI','ExcessCnt_TF','SpecificCnt_TF','AvgDays_TF','AvgFee_TF']; //指标数组
	var quotas_drgDepDayFeeTable = ['InCaseCnt','AvgDays','AvgFee','ExcessCnt_TF','SpecificCnt_TF','AvgDays_TF','AvgFee_TF']; //指标数组
	// 把指标传进去，通过递归查数据
	getTableData(0,"drgs",quotas_drgDayFeeTable,"drgDayFeeTable",drgDayFeeTableColumns,"hosp") ;
	if(roleName=="科室"){
		$("#"+tabId+" #drgDepDayFeeTable tr th").eq(1).html("主诊组");
		$("#"+tabId+" #depQuota13Tab").html("主诊组");
		getTableData(0,"clinic",quotas_drgDepDayFeeTable,"drgDepDayFeeTable",drgDepDayFeeTableColumns,"mdc") ;
	}else{
		getTableData(0,"dep",quotas_drgDepDayFeeTable,"drgDepDayFeeTable",drgDepDayFeeTableColumns,"mdc") ;
	}
	
});
